﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DemoApp1
{
    /// <summary>
    /// 位运算
    /// </summary>
    public class BitOperationDemo
    {
        /// <summary>
        /// 区别
        /// </summary>
        public void ShowDiff()
        {
            var t = bool.Parse("true");
            var f = bool.Parse("false");

            Console.WriteLine("0 | 1 => {0}", 0 | 1);
            Console.WriteLine("0 & 1 => {0}", 0 & 1);



            Console.WriteLine(" {0} | {1} => {2}", t, f, t | f);

            Console.WriteLine(" {0} & {1} => {2}", t, f, t & f);


            if (t || f)
            {
                Console.WriteLine("{0} || {1} => {2}", t, f, "成立");
            }
            else
            {
                Console.WriteLine("{0} || {1} => {2}", t, f, "不成立");
            }

            if (t && f)
            {
                Console.WriteLine("{0} && {1} => {2}", t, f, "成立");
            }
            else
            {
                Console.WriteLine("{0} && {1} => {2}", t, f, "不成立");
            }

            Console.WriteLine();
        }
    }
}
